package 异常;

public class demo05_finally {
    /*
    * 无论是否异常都需执行的代码放在finally中
    *  1.finally一般用于资源回收*/

    public static void main(String[] args) {
        try{
            m1("a.t");
        }catch (Exception e){
            System.out.println(e);
        }finally {
            System.out.println("释放资源");
        }

        System.out.println("后续代码");

    }

    private static void m1(String s) throws Exception{
        if(!s.endsWith(".txt")){
            throw new Exception("文件名错误!!!");
        }
    }
}
